#pragma once

#include <string>
#include "vector3d.h"
#include "transform4d.h"

class BoundingBox;
class Ray;
class Intersection;

typedef enum
{
	E_ObjType_Invalid = 0,
	E_ObjType_Reference,
	E_ObjType_TriMesh,
	E_ObjType_Cone,
	E_ObjType_Cylinder,
	E_ObjType_Box,
	E_ObjType_Sphere,
	E_MaxObjType
} EObjectType;

class Object3d
{
public:
	Object3d() : _type(E_ObjType_Invalid), _id(0) {}

	//Getters
	const string& GetName() const { return _name; }
	unsigned int GetId() const { return _id; }
	unsigned int GetMaterial() const { return _material; }
	unsigned int GetType() const { return _type; }
	const Transform4d& GetWorldTransform() const { return _transW; }

	//Setters
	void SetName(const string& str) { _name = str; }
	void SetId(unsigned int i) { _id = i; }
	void SetMaterial(unsigned int i) { _material = i; }
	void SetType(EObjectType t) { _type = t; }
	void SetWorldTransform(const Transform4d& t) { _transW = t; }

	//Overridable functions
	virtual void ComputeBoundingBox() = 0;
	virtual bool Intersect(const Ray& ray, Intersection& it) = 0;

	//Regular functions
	bool HitBoundingBox() const;

protected:

	string			_name;
	unsigned int	_id;
	EObjectType		_type;
	Transform4d		_transW;
	BoundingBox		_bbox;
	unsigned int	_material;
};